package Joe.HotSite.Web.Action;

import java.util.*;

import org.apache.struts2.ServletActionContext;

import Joe.HotSite.BLL.BannerProvider;
import Joe.HotSite.BLL.HotContentProvider;
import Joe.HotSite.BLL.HotPictureProvider;
import Joe.HotSite.BLL.Domain.*;

public class IndexAction {
	public List<Map> hcList = null;
	public List<Banner> bannerList = null;
	public Dictionary<Integer,String> picUrlList = new Hashtable<Integer,String>();
	public void setHc(List<Map> hc) {
		this.hcList = hc;
	}

	public List<Map> getHcList() {
		return hcList;
	}

	public void setHcList(List<Map> hcList) {
		this.hcList = hcList;
	}

	public List<Banner> getBannerList() {
		return bannerList;
	}

	public Dictionary<Integer, String> getPicUrlList() {
		return picUrlList;
	}

	public void setPicUrlList(Dictionary<Integer, String> picUrlList) {
		this.picUrlList = picUrlList;
	}

	public void setBannerList(List<Banner> bannerList) {
		this.bannerList = bannerList;
	}

	public List<Map> getHc() {
		return hcList;
	}

	public String execute() throws Exception {
		this.hcList = HotContentProvider.getInstance().getMap();
		this.bannerList = BannerProvider.getInstance().getList();
		List<Integer> pidList = new ArrayList<Integer>();
		for(Banner hp : bannerList){
			//pidList.add(hp.getPid()); 
		}
		Integer[] pids = pidList.toArray(new Integer[0]);
		List<Hotpicture> hpList = HotPictureProvider.getInstance().getPicturebyPids(pids);
        //for(Hotpicture hp : hpList){
		//	this.picUrlList.put(hp.getPid(), hp.getUri());
		//}
		//String url = ServletActionContext.getRequest().getServletPath();
		//${pageContext.request.getServletPath()}']
		return "success";
	}
}
